package servlet;

import pojo.User;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;


/**
 * 12-请求参数的封装
 * ①手动封装
 */
@WebServlet("/demo16")
public class Demo16Servlet extends HttpServlet {
    protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
        //①手动获取所有参数值
        String username = request.getParameter("username");
        String password = request.getParameter("password");
        //②手动将所有参数值封装到javabean中
        User user = new User(username,password);
        show(user);
    }

    public void show(User user) {
        System.out.println("username = " + user.getUsername());
        System.out.println("password = " + user.getPassword());
    }

    protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
        doPost(request, response);
    }
}
